package com.ou.csbs.capstone.models.shapes.control;

import gov.nasa.worldwind.geom.LatLon;
import gov.nasa.worldwind.geom.Position;

import java.util.ArrayList;

import com.ou.csbs.capstone.models.RenderableModel;
import com.ou.csbs.capstone.views.worldwind.WorldWindCanvas;
/**
 * This list is used to store all Control points that are related to a selected object. Once all Control points have been added to it's list, and all have been added to the RenderableLayer,
 * they are all drawn at the same time.
 * 
 * @author Senior Capstone
 */
public class ShapeControlList {
	private RenderableModel model;
	private ArrayList<ControlPoint> controlPoints;
	
	public ShapeControlList(RenderableModel model){
		this.model = model;
		this.controlPoints = new ArrayList<ControlPoint>();
	}
	public void updateControlPoints(Iterable<? extends LatLon> iterable){
		removeControlPoints();
		for(LatLon p: iterable){
			this.controlPoints.add(new ControlPoint((Position) p));
		}
	}
	public void updateControlPoints(Position position){
		removeControlPoints();
		this.controlPoints.add(new ControlPoint(position));
	}
	public void removeControlPoints(){
		for(ControlPoint point: this.controlPoints){
			point.removePoint(this.model);
		}
		this.controlPoints.clear();
		WorldWindCanvas.getWorldWindow().redrawNow();
	}
	public void drawControlPoints(){
		for(ControlPoint point: this.controlPoints){
			point.drawPoint(this.model);
		}
		WorldWindCanvas.getWorldWindow().redrawNow();
	}
	public ArrayList<ControlPoint> getControlPoints(){
		return this.controlPoints;
	}
}
